package com.cardone.platform.common.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;


import lombok.Getter;


import lombok.Setter;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.cardone.common.dto.PaginationDto;
import com.cardone.common.cache.Caches;
import com.cardone.context.Attributes;
import com.cardone.context.ContextHolder;
import com.cardone.common.util.EntityUtils;
import com.cardone.platform.common.dao.EntityDefaultDao;
import com.cardone.platform.common.dto.EntityDefaultDto;

/**
 * 实体与默认服务
 *
 * @author yaohaitao
 * 
 */
@Getter 
@Setter
@Transactional(readOnly = true)
public class EntityDefaultDefaultService implements EntityDefaultService {
	@Override
	@Transactional
	public <P> P saveByIdOrCode(Class<P> mappedClass, EntityDefaultDto saveEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).saveByIdOrCode(mappedClass, saveEntityDefault);
	}
	
	@Override
	@Transactional
	public EntityDefaultDto saveByIdOrCode(EntityDefaultDto saveEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).saveByIdOrCode(EntityDefaultDto.class, saveEntityDefault);
	}
	
	@Override
	public <P> P findByCodeOrId(Class<P> mappedClass, EntityDefaultDto findEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).findByCodeOrId(mappedClass, findEntityDefault);
	}
	
	@Override
	public Integer readByCodeNqIdForCount(EntityDefaultDto readEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).readByCodeNqIdForCount(readEntityDefault);
	}
	
	@Override
	@Transactional
	public int insertByCode(EntityDefaultDto insertEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).insertByCode(insertEntityDefault);
	}
	
	@Override
	@Transactional
	public int updateByCode(EntityDefaultDto updateEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).updateByCode(updateEntityDefault);
	}

	@Override
	@Transactional
	public int deleteByIds(EntityDefaultDto deleteEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).deleteByIds(deleteEntityDefault);
	}

	@Override
	public <P> P findById(Class<P> mappedClass, EntityDefaultDto findEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).findById(mappedClass, findEntityDefault);
	}

	@Override
	public <P> List<P> findListByLikeCode(Class<P> mappedClass, EntityDefaultDto findListEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).findListByLikeCode(mappedClass, findListEntityDefault);
	}

	@Override
	public <P> List<P> findList(Class<P> mappedClass) {
		return ContextHolder.getBean(EntityDefaultDao.class).findList(mappedClass);
	}

	@Override
	public <P> PaginationDto<P> paginationByLikeCode(Class<P> mappedClass, EntityDefaultDto paginationEntityDefault) {
		return ContextHolder.getBean(EntityDefaultDao.class).paginationByLikeCode(mappedClass, paginationEntityDefault);
	}
}